/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.alphawavesgames.engine.maths;

/**
 *
 * @author duncan
 */
public class Vector3 extends Vector2
{
    private float m_z;

    public Vector3()
    {
        m_z = 0.0f;
    }

    public Vector3( float initAll )
    {
        super( initAll );
        m_z = initAll;
    }

    public Vector3( float x, float y, float z )
    {
        super( x,y );
        m_z = z;
    }

    public Vector3( Vector2 vec2 )
    {
        super( vec2 );
        m_z = 0.0f;
    }

    public Vector3( Vector3 vec3 )
    {
        super( vec3.getX(), vec3.getY() );
        m_z = 0.0f;
    }

    public void setZ( float z ) { m_z = z; }
    public float getZ() { return m_z; }

    public Vector3 add( Vector3 otherVec )
    {
        m_x += otherVec.m_x;
        m_y += otherVec.m_y;
        m_z += otherVec.m_z;
        return this;
    }

    public Vector3 sub( Vector3 otherVec )
    {
        m_x -= otherVec.m_x;
        m_y -= otherVec.m_y;
        m_z -= otherVec.m_z;
        return this;
    }

    public Vector3 componentMul( Vector3 otherVec )
    {
        m_x *= otherVec.m_x;
        m_y *= otherVec.m_y;
        m_z *= otherVec.m_z;
        return this;
    }

    @Override
    public Vector3 scalarMul( float scalar )
    {
        m_x *= scalar;
        m_y *= scalar;
        m_z *= scalar;
        return this;
    }

    public Vector3 componentDiv( Vector3 otherVec )
    {
        m_x /= otherVec.m_x;
        m_y /= otherVec.m_y;
        m_z /= otherVec.m_z;
        return this;
    }

    @Override
    public Vector3 scalarDiv( float scalar )
    {
        m_x /= scalar;
        m_y /= scalar;
        m_z /= scalar;
        return this;
    }

    public float dot( Vector3 otherVec )
    {
        return (m_x * otherVec.m_x) + (m_y * otherVec.m_y) + (m_z * otherVec.m_z);
    }
}
